package com.xu.ai.mcpserver.service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.springframework.ai.tool.annotation.Tool;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;

/**
 * @author xuguan
 * @since 2025/8/4
 */
@Service
public class DateTimeTool implements IMcpTool {

	@Tool(name = "getDateTime", description = "获取日期时间")
	public String getDateTime() {
		final LocalDateTime dateTime = LocalDateTime.now(LocaleContextHolder.getTimeZone().toZoneId());
		final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
		return formatter.format(dateTime);
	}

	@Tool(name = "getDate", description = "获取日期")
	public String getDate() {
		final LocalDateTime dateTime = LocalDateTime.now(LocaleContextHolder.getTimeZone().toZoneId());
		final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
		return formatter.format(dateTime);
	}

	@Tool(name = "getTime", description = "获取时间")
	public String getTime() {
		final LocalDateTime dateTime = LocalDateTime.now(LocaleContextHolder.getTimeZone().toZoneId());
		final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
		return formatter.format(dateTime);
	}

}
